﻿using System;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics;

namespace Domain
{
    /// <summary>
    /// 实体模型基础类
    /// 要求所有实体派生于此类   
    /// </summary> 
    [DebuggerDisplay("ID = {ID}")]
    [Serializable]
    public class EntityBase
    {
        /// <summary>
        /// ID
        /// </summary>
        [Key]
        [Required]
        public Guid ID { get; set; }

        public EntityBase()
        {
            this.ID = Guid.NewGuid();
        }
    }

    /// <summary>
    /// 包含ID、创建时间、是否有效字段的实体
    /// </summary>
    [Serializable]
    public class Entity : EntityBase
    {
        /// <summary>
        /// 状态
        /// </summary>
        public bool IsValid { get; set; }

        /// <summary>
        /// 创建日期
        /// </summary>
        public DateTime CreateTime { get; set; }

        public Entity()           
        {           
            this.CreateTime = DateTime.Now;
            this.IsValid = true;
        }
    }

}
